package com.hqyj.ssm_project.service;

import com.hqyj.ssm_project.mapper.RoleMapper;
import com.hqyj.ssm_project.mapper.Role_FunctionMapper;
import com.hqyj.ssm_project.mapper.User_RoleMapper;
import com.hqyj.ssm_project.pojo.Function;
import com.hqyj.ssm_project.pojo.Role;
import com.hqyj.ssm_project.pojo.Role_Function;
import com.hqyj.ssm_project.pojo.User_Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImp implements RoleService {
    @Autowired
    private RoleMapper roleMapper;
    @Autowired
    private User_RoleMapper user_roleMapper;
    @Autowired
    private Role_FunctionMapper role_functionMapper;

    @Override
    public int deleteByPrimaryKey(Integer roleId) {
        return roleMapper.deleteByPrimaryKey(roleId);
    }

    @Override
    public int insert(Role row) {
        return roleMapper.insert(row);
    }

    @Override
    public int insertSelective(Role row) {
        return roleMapper.insertSelective(row);
    }

    @Override
    public Role selectByPrimaryKey(Integer roleId) {
        return roleMapper.selectByPrimaryKey(roleId);
    }

    @Override
    public int updateByPrimaryKeySelective(Role row) {
        return roleMapper.updateByPrimaryKeySelective(row);
    }

    @Override
    public int updateByPrimaryKey(Role row) {
        return roleMapper.updateByPrimaryKey(row);
    }

    @Override
    public List<Role> selectAllRole() {
        return roleMapper.selectAllRole();
    }
    @Override
    public void deleteFromRole_Function(Integer id) {
        roleMapper.deleteFromRole_Function(id);
    }

    @Override
    public void setRole(User_Role user_role) {
        user_roleMapper.insert(user_role);
    }

    @Override
    public void deletUser_Role(Integer userId) {
        user_roleMapper.deletUser_Role(userId);
    }

    @Override
    public User_Role seleteUser_RoleByUserId(Integer userId) {
        return user_roleMapper.seleteUser_RoleByUserId(userId);
    }

    @Override
    public List<Role_Function> selectRole_Function() {
        return role_functionMapper.selectRole_Function();
    }

    @Override
    public void addFunctionToRole(Role_Function role_function) {
        role_functionMapper.insert(role_function);
    }

    @Override
    public Role_Function selectRole_FunctionByfunctionIdAndRoleId(Role_Function role_function) {
        return role_functionMapper.selectRole_FunctionByfunctionIdAndRoleId(role_function);
    }

    @Override
    public void insertRole_Function(Role_Function role_function) {
        role_functionMapper.insert(role_function);
    }

    @Override
    public void deleteRole_Function(Role_Function role_function) {
        role_functionMapper.deleteRole_Function(role_function);
    }

    @Override
    public List<Role> selectRoleAndUser() {
        return roleMapper.selectRoleAndUser();
    }

    @Override
    public Role selectRoleByRoleName(String superRoleName) {
        return roleMapper.selectRoleByRoleName(superRoleName);
    }


}
